package com.dunqi.gpm.shunqing.home.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.dunqi.gpm.shunqing.R;
import com.dunqi.gpm.shunqing.common.base.BaseAct;
import com.dunqi.gpm.shunqing.develop.widget.DrawLeftRadioButton;
import com.dunqi.gpm.shunqing.home.bean.EarlyInfo;
import com.dunqi.gpm.shunqing.home.widget.NormalView;

import butterknife.BindView;

public class ApprovalReviewDetailActivity extends BaseAct {

    private static final String DATA = "data";
    @BindView(R.id.audit_status_view)
    NormalView auditStatusView;
    @BindView(R.id.nick_name_view)
    NormalView nickNameView;
    @BindView(R.id.company_view)
    NormalView companyView;
    @BindView(R.id.name_view)
    NormalView nameView;
    @BindView(R.id.project_name_view)
    NormalView projectNameView;
    @BindView(R.id.phone_view)
    NormalView phoneView;
    @BindView(R.id.level_view)
    NormalView levelView;
    @BindView(R.id.cycle_view)
    NormalView cycleView;
    @BindView(R.id.is_completed_view)
    NormalView isCompletedView;
    @BindView(R.id.plan_start_time_view)
    NormalView planStartTimeView;
    @BindView(R.id.plan_end_time_view)
    NormalView planEndTimeView;
    @BindView(R.id.actual_start_time_view)
    NormalView actualStartTimeView;
    @BindView(R.id.actual_end_time_view)
    NormalView actualEndTimeView;
    @BindView(R.id.question_view)
    NormalView questionView;
    @BindView(R.id.remarks_view)
    NormalView remarksView;
    @BindView(R.id.comfig_tv)
    DrawLeftRadioButton comfigTv;

    String[] stageStatuss = new String[]{"待申请", "待完成", "已完成"};
    EarlyInfo item;

    @Override
    protected void refreshData(Bundle savedInstanceState) {

    }

    @Override
    protected void initUiAndListener() {
        item = (EarlyInfo) getIntent().getSerializableExtra(DATA);

        refreshUI();

        comfigTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (item == null) {
                    return;
                }
                String stageName = item.getStageName();
                long proAnnualPlanPreStageId = item.getProAnnualPlanPreStageId();
                CompleteEarlyInfoActivity.start(getActivity(), proAnnualPlanPreStageId, stageName);
            }
        });
    }

    public static void start(Context context, EarlyInfo item) {
        Intent intent = new Intent(context, ApprovalReviewDetailActivity.class);
        intent.putExtra(DATA, item);
        context.startActivity(intent);
    }

    private void refreshUI() {
        if (item == null) {
            return;
        }
        projectNameView.setText(item.getProjectName());

        nickNameView.setText(item.getStageName());

        companyView.setText(item.getRespOrgName());

        nameView.setText(item.getRespOrgLeaderName());

        phoneView.setText(item.getRespOrgLeaderPhone());

        levelView.setText(item.getAuditLevelText());

        cycleView.setText(String.valueOf(item.getIntervalDays()));

        isCompletedView.setText(item.getStageStatus() == 2 ? "是" : "否");

        planStartTimeView.setText(item.getPlanStartTime());
        planEndTimeView.setText(item.getPlanCompleteTime());

        actualStartTimeView.setText(item.getActualStartTime());

        actualEndTimeView.setText(item.getActualCompleteTime());

        questionView.setText(item.getExistedProblem());

        remarksView.setText(item.getRemark());

        int stageStatus = item.getStageStatus();


        auditStatusView.setText(stageStatuss[stageStatus]);
        if (stageStatus == 0) {
            auditStatusView.setTextColor(R.color.red);
        } else {
            auditStatusView.setTextColor(R.color.text_color_select_gray);
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_approval_review_detail;
    }


}
